import request from 'utils/request.js'

// 商品轮播图
const fetchBanner = (params = {}) => request.get('/banner/list', {
  params
})

// 商品类别s
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', {
  params
})
// 商品列表
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2',
  params)
// 商品详情页
const fetchDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
// 用户注册
const Register = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const Login = (params = {}) => request.post('/user/username/login', params)

// 获取购物车数据
const CartItems = (params = {}) => request.get('/shopping-cart/info', { params })

// 加入购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)

// 修改商品数量
const changeStepper = (params = {}) => request.post('/shopping-cart/modifyNumber', params)

// 改变商品选中状态
const switchItem = (params = {}) => request.post('/shopping-cart/select', params)

// 删除商品
const delList = (params = {}) => request.post('/shopping-cart/remove', params)

// 添加收货地址
const addContent = (params = {}) => request.get('/user/shipping-address/add', {
  params
})

// 获取联系人地址
const fetchContacts = (params = {}) => request.post('/user/shipping-address/list/v2',
  params
)

// 修改联系人信息
const UpdateContacts = (params = {}) => request.post('/user/shipping-address/update',
  params
)

// 获取联系人的个人详情
const getContent = (params = {}) => request.get('/user/shipping-address/detail/v2', {
  params
})

// 获取默认收货地址
const DefaultAddress = (params = {}) => request.get('/user/shipping-address/default/v2', {
  params
})

// 删除联系人信息
const DelContacts = (params = {}) => request.post('/user/shipping-address/delete',
  params
)

export {
  fetchBanner,
  fetchCates,
  fetchItems,
  fetchDetail,
  Register,
  Login,
  CartItems,
  addCart,
  changeStepper,
  switchItem,
  delList,
  addContent,
  fetchContacts,
  UpdateContacts,
  getContent,
  DefaultAddress,
  DelContacts
}
